#include <interrupt.h>
#include <printk.h>
#include <types.h>

uint8_t _preempt = 0;                               /*   记录中断抢占   */
irq_handler_t irq_handler_table[NR_IRQS];           /*   记录中断抢占   */


int irq_default_handler(int irq)
{
    printk("[irq %d]: happened\n",irq);
    return RSP_IRQ_OK;
}

int register_irq(int irq, irq_handler_t handler)
{
    if(irq > NR_IRQS || irq < 0){
        printk("irq: %d.register irq over bounds.\n", irq);
        return -EPERM;
    }
    irq_handler_table[irq] = handler;
    return 0;
}

void irq_init(void)
{
    int i = 0;
    for(;i < NR_IRQS; i++)
        irq_handler_table[i] = irq_default_handler;
}